package com.sayice.robotconflict.game.object.logic;

import com.sayice.robotconflict.game.object.Robot;
import com.sayice.robotconflict.game.object.Team;
import com.sayice.robotconflict.game.object.property.SimpleCoord;

import java.util.function.BiFunction;

/**
 * 复杂获取函数
 *
 * @author shubing
 */
public enum ComplexGetFunc {
    GET_TOWER_POS((robot, params) -> new SimpleCoord(robot.player.team.towerCoord)),
    
    GET_RIVAL_TOWER_POS((robot, params) -> {
        Team team = robot.player.team;
        return new SimpleCoord(team.room.rivalOf(team).towerCoord);
    }),
    
    GET_ANY_RIVAL_ROBOT_POS((robot, params) -> {
        Team team = robot.player.team;
        for (Robot rivalRobot : team.room.rivalOf(team).robots) {
            return new SimpleCoord(rivalRobot.coord);
        }
        return null;
    });
    
    private BiFunction<Robot, Object[], Object> fn;
    
    ComplexGetFunc(BiFunction<Robot, Object[], Object> fn) {
        this.fn = fn;
    }
    
    public Object get(Robot robot, Object... params) {
        return fn.apply(robot, params);
    }
}
